class Solution(object):
    def maxNumberOfApples(self, weight):
        """
        :type weight: List[int]
        :rtype: int
        """
        weight.sort()
        count = 0
        i = 0
        while i < len(weight):
            count += weight[i]
            if count > 5000:
                return i
            else:
                i += 1
        return i
